<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="__PUBLIC__/Js/home/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/layer/layer.js"></script>
    <style>
        .evaluate{
            margin: 10px auto;
            width:300px;
            height: 250px;
        }
        .evaluate .textarea{
            width: 300px;
            height:200px;
        }
        .evaluate .btn{
            width: 300px;
            height:50px;
            text-align: right;
        }
        .evaluate a{
            color:black;
            margin-bottom: 10px;
            padding: 5px 10px;
            background-color: pink;
        }
        .evaluate a:hover{
            background-color: #D6B870;
        }
    </style>
    <script>
        function saveEvaluate(order_detail_id,goods_id,status){
            var content= $.trim($('#evaluate').val());
            if(content==''){
                $('.evaluate').prepend('<div class="error" style="color: red;font-size: 12px">评论内容不能为空</div>');
                return;
            }else{
                $('.error').remove();
            }
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            layer.load(1);
            $.post(
                    '__URL__/evaluate_edit',
                    {order_detail_id:order_detail_id,goods_id:goods_id,status:status,content:content},
                    function(data){
                        layer.closeAll('loading');
                        if(data['status']==1){
                            if(status==0){
                                parent.layer.msg(data['content'],{time:1000});
                                //删除已评论过的商品
                                parent.$('#evaluate'+order_detail_id).remove();
                                //初次评论时调取父页面的函数改变未评论的数量
                                window.parent.change_num();
                            }else{
                                parent.$('.member_all-nav-ul li:eq(1)').click();
                            }
                            //关闭iframe弹框
                            parent.layer.close(index);
                        }else{
                            layer.alert(data['content']);
                        }
                    },
                    'json'
            );
        }
    </script>
</head>
<body>
<div class="evaluate">
    <div class="textarea">
        <textarea id="evaluate" cols="40" rows="10" placeholder="请输入评论内容，字数在50字以内" maxlength="50"></textarea>
    </div>
    <div class="btn">
        <a href="javascript:saveEvaluate({$Think.get.order_detail_id},{$Think.get.goods_id},{$Think.get.status})" class="btn">提交</a>
    </div>
</div>
</body>
</html>